package com.projects.android.dto;

import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

public class DistrictDTO {
	private int ID;
	private int IDCity;
	private String Name;
	private ArrayList<RestaurantDTO> Restaurants;

	public String toString(){
		return Name;
	}
	
	public void initObject(JSONObject data) {
		try {
			ID = Integer.valueOf(data.getString("ID"));
			IDCity = Integer.valueOf(data.getString("IDCity"));
			Name = data.getString("Name");
			Restaurants = new ArrayList<RestaurantDTO>();
//			JSONArray arrData = new JSONArray(data.getString("Restaurants"));
//			// Loop for all reveived objects
//			for (int i = 0; i < arrData.length(); i++) {
//				JSONObject dataChild = (JSONObject) arrData.get(i);
//				RestaurantDTO dto = new RestaurantDTO();
//				dto.initObject(dataChild);
//				Restaurants.add(dto);
//			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			Log.e("Init DistrictDTO", e.toString());
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			Log.e("Init DistrictDTO", e.toString());
		}
	}

	public int getID() {
		return ID;
	}

	public void setID(int iD) {
		ID = iD;
	}

	public int getIDCity() {
		return IDCity;
	}

	public void setIDCity(int iDCity) {
		IDCity = iDCity;
	}

	public String getName() {
		return Name;
	}

	public void setName(String name) {
		Name = name;
	}

	public ArrayList<RestaurantDTO> getRestaurants() {
		return Restaurants;
	}

	public void setRestaurants(ArrayList<RestaurantDTO> restaurants) {
		Restaurants = restaurants;
	}
}
